home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / OPTIMIZE / CODE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-16  |  17.3 KB  |  536 lines

  1. VERSION 5.00
  2. Begin VB.Form Code 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Code Optimizations"
  5.    ClientHeight    =   5220
  6.    ClientLeft      =   870
  7.    ClientTop       =   1515
  8.    ClientWidth     =   6975
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    LinkTopic       =   "Form1"
  20.    LockControls    =   -1  'True
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    PaletteMode     =   1  'UseZOrder
  24.    ScaleHeight     =   5220
  25.    ScaleWidth      =   6975
  26.    ShowInTaskbar   =   0   'False
  27.    Tag             =   "Real"
  28.    WhatsThisHelp   =   -1  'True
  29.    Begin VB.TextBox txtLoopCount 
  30.       Height          =   320
  31.       Left            =   5600
  32.       TabIndex        =   8
  33.       Text            =   "txtLoopCount"
  34.       Top             =   3765
  35.       Width           =   1300
  36.    End
  37.    Begin VB.CommandButton cmdExplicit 
  38.       Caption         =   "Explict Property"
  39.       BeginProperty Font 
  40.          Name            =   "MS Sans Serif"
  41.          Size            =   8.25
  42.          Charset         =   0
  43.          Weight          =   400
  44.          Underline       =   0   'False
  45.          Italic          =   0   'False
  46.          Strikethrough   =   0   'False
  47.       EndProperty
  48.       Height          =   450
  49.       Left            =   120
  50.       TabIndex        =   2
  51.       Top             =   2280
  52.       Width           =   1935
  53.    End
  54.    Begin VB.CommandButton cmdVariable 
  55.       Caption         =   "Variable Test"
  56.       BeginProperty Font 
  57.          Name            =   "MS Sans Serif"
  58.          Size            =   8.25
  59.          Charset         =   0
  60.          Weight          =   400
  61.          Underline       =   0   'False
  62.          Italic          =   0   'False
  63.          Strikethrough   =   0   'False
  64.       EndProperty
  65.       Height          =   450
  66.       Left            =   120
  67.       TabIndex        =   1
  68.       Top             =   960
  69.       Width           =   1935
  70.    End
  71.    Begin VB.CommandButton cmdVariant 
  72.       Caption         =   "Variant Counter"
  73.       BeginProperty Font 
  74.          Name            =   "MS Sans Serif"
  75.          Size            =   8.25
  76.          Charset         =   0
  77.          Weight          =   400
  78.          Underline       =   0   'False
  79.          Italic          =   0   'False
  80.          Strikethrough   =   0   'False
  81.       EndProperty
  82.       Height          =   450
  83.       Left            =   120
  84.       TabIndex        =   4
  85.       Top             =   4190
  86.       Width           =   1935
  87.    End
  88.    Begin VB.CommandButton cmdInteger 
  89.       Caption         =   "Integer Counter"
  90.       BeginProperty Font 
  91.          Name            =   "MS Sans Serif"
  92.          Size            =   8.25
  93.          Charset         =   0
  94.          Weight          =   400
  95.          Underline       =   0   'False
  96.          Italic          =   0   'False
  97.          Strikethrough   =   0   'False
  98.       EndProperty
  99.       Height          =   450
  100.       Left            =   120
  101.       TabIndex        =   5
  102.       Top             =   4680
  103.       Width           =   1935
  104.    End
  105.    Begin VB.TextBox txtValue 
  106.       Height          =   320
  107.       Left            =   5600
  108.       TabIndex        =   7
  109.       Text            =   "txtValue"
  110.       Top             =   1800
  111.       Width           =   1300
  112.    End
  113.    Begin VB.CommandButton cmdValue 
  114.       Caption         =   "Value of the Control"
  115.       BeginProperty Font 
  116.          Name            =   "MS Sans Serif"
  117.          Size            =   8.25
  118.          Charset         =   0
  119.          Weight          =   400
  120.          Underline       =   0   'False
  121.          Italic          =   0   'False
  122.          Strikethrough   =   0   'False
  123.       EndProperty
  124.       Height          =   450
  125.       Left            =   120
  126.       TabIndex        =   3
  127.       Top             =   2780
  128.       Width           =   1935
  129.    End
  130.    Begin VB.TextBox txtCounter 
  131.       Height          =   320
  132.       Left            =   5600
  133.       TabIndex        =   6
  134.       Text            =   "txtCounter"
  135.       Top             =   60
  136.       Width           =   1300
  137.    End
  138.    Begin VB.CommandButton cmdProperty 
  139.       Caption         =   "Property Test"
  140.       Default         =   -1  'True
  141.       BeginProperty Font 
  142.          Name            =   "MS Sans Serif"
  143.          Size            =   8.25
  144.          Charset         =   0
  145.          Weight          =   400
  146.          Underline       =   0   'False
  147.          Italic          =   0   'False
  148.          Strikethrough   =   0   'False
  149.       EndProperty
  150.       Height          =   450
  151.       Left            =   120
  152.       TabIndex        =   0
  153.       Top             =   480
  154.       Width           =   1935
  155.    End
  156.    Begin VB.Line Line1 
  157.       BorderColor     =   &H00808080&
  158.       Index           =   3
  159.       X1              =   -15
  160.       X2              =   7320
  161.       Y1              =   3465
  162.       Y2              =   3465
  163.    End
  164.    Begin VB.Line Line1 
  165.       BorderColor     =   &H00FFFFFF&
  166.       BorderWidth     =   2
  167.       Index           =   2
  168.       X1              =   0
  169.       X2              =   7335
  170.       Y1              =   3480
  171.       Y2              =   3465
  172.    End
  173.    Begin VB.Line Line1 
  174.       BorderColor     =   &H00808080&
  175.       Index           =   1
  176.       X1              =   0
  177.       X2              =   7335
  178.       Y1              =   1680
  179.       Y2              =   1680
  180.    End
  181.    Begin VB.Label lblTitle 
  182.       Appearance      =   0  'Flat
  183.       AutoSize        =   -1  'True
  184.       BackColor       =   &H00FFFFFF&
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "Integer vs. Variant Variables"
  187.       BeginProperty Font 
  188.          Name            =   "MS Sans Serif"
  189.          Size            =   12
  190.          Charset         =   0
  191.          Weight          =   700
  192.          Underline       =   0   'False
  193.          Italic          =   0   'False
  194.          Strikethrough   =   0   'False
  195.       EndProperty
  196.       ForeColor       =   &H00800000&
  197.       Height          =   300
  198.       Index           =   0
  199.       Left            =   120
  200.       TabIndex        =   21
  201.       Top             =   3750
  202.       Width           =   3675
  203.    End
  204.    Begin VB.Label lblTitle 
  205.       Appearance      =   0  'Flat
  206.       AutoSize        =   -1  'True
  207.       BackColor       =   &H00FFFFFF&
  208.       BackStyle       =   0  'Transparent
  209.       Caption         =   "Explicit property vs. Value of the Control"
  210.       BeginProperty Font 
  211.          Name            =   "MS Sans Serif"
  212.          Size            =   12
  213.          Charset         =   0
  214.          Weight          =   700
  215.          Underline       =   0   'False
  216.          Italic          =   0   'False
  217.          Strikethrough   =   0   'False
  218.       EndProperty
  219.       ForeColor       =   &H00800000&
  220.       Height          =   300
  221.       Index           =   2
  222.       Left            =   120
  223.       TabIndex        =   20
  224.       Top             =   1800
  225.       Width           =   5550
  226.    End
  227.    Begin VB.Label lblTitle 
  228.       Appearance      =   0  'Flat
  229.       AutoSize        =   -1  'True
  230.       BackColor       =   &H00FFFFFF&
  231.       BackStyle       =   0  'Transparent
  232.       Caption         =   "Variables vs. Property Access"
  233.       BeginProperty Font 
  234.          Name            =   "MS Sans Serif"
  235.          Size            =   12
  236.          Charset         =   0
  237.          Weight          =   700
  238.          Underline       =   0   'False
  239.          Italic          =   0   'False
  240.          Strikethrough   =   0   'False
  241.       EndProperty
  242.       ForeColor       =   &H00800000&
  243.       Height          =   300
  244.       Index           =   1
  245.       Left            =   120
  246.       TabIndex        =   19
  247.       Top             =   120
  248.       Width           =   3855
  249.    End
  250.    Begin VB.Label lblVariant 
  251.       Appearance      =   0  'Flat
  252.       BackColor       =   &H80000005&
  253.       BackStyle       =   0  'Transparent
  254.       Caption         =   "00.00 secs"
  255.       BeginProperty Font 
  256.          Name            =   "MS Sans Serif"
  257.          Size            =   9.75
  258.          Charset         =   0
  259.          Weight          =   700
  260.          Underline       =   0   'False
  261.          Italic          =   0   'False
  262.          Strikethrough   =   0   'False
  263.       EndProperty
  264.       ForeColor       =   &H80000008&
  265.       Height          =   250
  266.       Left            =   5600
  267.       TabIndex        =   18
  268.       Top             =   4290
  269.       Width           =   1800
  270.    End
  271.    Begin VB.Label lblInteger 
  272.       Appearance      =   0  'Flat
  273.       BackColor       =   &H80000005&
  274.       BackStyle       =   0  'Transparent
  275.       Caption         =   "00.00 secs"
  276.       BeginProperty Font 
  277.          Name            =   "MS Sans Serif"
  278.          Size            =   9.75
  279.          Charset         =   0
  280.          Weight          =   700
  281.          Underline       =   0   'False
  282.          Italic          =   0   'False
  283.          Strikethrough   =   0   'False
  284.       EndProperty
  285.       ForeColor       =   &H80000008&
  286.       Height          =   250
  287.       Left            =   5600
  288.       TabIndex        =   17
  289.       Top             =   4785
  290.       Width           =   1800
  291.    End
  292.    Begin VB.Label Label1 
  293.       Appearance      =   0  'Flat
  294.       BackColor       =   &H80000005&
  295.       BackStyle       =   0  'Transparent
  296.       Caption         =   "Use the explicit Text property:"
  297.       ForeColor       =   &H80000008&
  298.       Height          =   250
  299.       Index           =   3
  300.       Left            =   2145
  301.       TabIndex        =   16
  302.       Top             =   2385
  303.       Width           =   2700
  304.    End
  305.    Begin VB.Label lblExplicit 
  306.       Appearance      =   0  'Flat
  307.       BackColor       =   &H80000005&
  308.       BackStyle       =   0  'Transparent
  309.       Caption         =   "00.00 secs"
  310.       BeginProperty Font 
  311.          Name            =   "MS Sans Serif"
  312.          Size            =   9.75
  313.          Charset         =   0
  314.          Weight          =   700
  315.          Underline       =   0   'False
  316.          Italic          =   0   'False
  317.          Strikethrough   =   0   'False
  318.       EndProperty
  319.       ForeColor       =   &H80000008&
  320.       Height          =   250
  321.       Left            =   5600
  322.       TabIndex        =   15
  323.       Top             =   2385
  324.       Width           =   1300
  325.    End
  326.    Begin VB.Label Label1 
  327.       Appearance      =   0  'Flat
  328.       BackColor       =   &H80000005&
  329.       BackStyle       =   0  'Transparent
  330.       Caption         =   "Use value of the control:"
  331.       ForeColor       =   &H80000008&
  332.       Height          =   250
  333.       Index           =   2
  334.       Left            =   2145
  335.       TabIndex        =   14
  336.       Top             =   2880
  337.       Width           =   2700
  338.    End
  339.    Begin VB.Label lblValue 
  340.       Appearance      =   0  'Flat
  341.       BackColor       =   &H80000005&
  342.       BackStyle       =   0  'Transparent
  343.       Caption         =   "00.00 secs"
  344.       BeginProperty Font 
  345.          Name            =   "MS Sans Serif"
  346.          Size            =   9.75
  347.          Charset         =   0
  348.          Weight          =   700
  349.          Underline       =   0   'False
  350.          Italic          =   0   'False
  351.          Strikethrough   =   0   'False
  352.       EndProperty
  353.       ForeColor       =   &H80000008&
  354.       Height          =   250
  355.       Left            =   5600
  356.       TabIndex        =   13
  357.       Top             =   2880
  358.       Width           =   1300
  359.    End
  360.    Begin VB.Line Line1 
  361.       BorderColor     =   &H00FFFFFF&
  362.       BorderWidth     =   2
  363.       Index           =   0
  364.       X1              =   15
  365.       X2              =   7350
  366.       Y1              =   1695
  367.       Y2              =   1680
  368.    End
  369.    Begin VB.Label lblVariable 
  370.       Appearance      =   0  'Flat
  371.       BackColor       =   &H80000005&
  372.       BackStyle       =   0  'Transparent
  373.       Caption         =   "00.00 secs"
  374.       BeginProperty Font 
  375.          Name            =   "MS Sans Serif"
  376.          Size            =   9.75
  377.          Charset         =   0
  378.          Weight          =   700
  379.          Underline       =   0   'False
  380.          Italic          =   0   'False
  381.          Strikethrough   =   0   'False
  382.       EndProperty
  383.       ForeColor       =   &H80000008&
  384.       Height          =   250
  385.       Left            =   5600
  386.       TabIndex        =   12
  387.       Top             =   1080
  388.       Width           =   1300
  389.    End
  390.    Begin VB.Label Label1 
  391.       Appearance      =   0  'Flat
  392.       BackColor       =   &H80000005&
  393.       BackStyle       =   0  'Transparent
  394.       Caption         =   "Using a Variable in the loop:"
  395.       ForeColor       =   &H80000008&
  396.       Height          =   250
  397.       Index           =   1
  398.       Left            =   2145
  399.       TabIndex        =   11
  400.       Top             =   1080
  401.       Width           =   3100
  402.    End
  403.    Begin VB.Label lblProperty 
  404.       Appearance      =   0  'Flat
  405.       BackColor       =   &H80000005&
  406.       BackStyle       =   0  'Transparent
  407.       Caption         =   "00.00 secs"
  408.       BeginProperty Font 
  409.          Name            =   "MS Sans Serif"
  410.          Size            =   9.75
  411.          Charset         =   0
  412.          Weight          =   700
  413.          Underline       =   0   'False
  414.          Italic          =   0   'False
  415.          Strikethrough   =   0   'False
  416.       EndProperty
  417.       ForeColor       =   &H80000008&
  418.       Height          =   250
  419.       Left            =   5600
  420.       TabIndex        =   10
  421.       Top             =   585
  422.       Width           =   1300
  423.    End
  424.    Begin VB.Label Label1 
  425.       Appearance      =   0  'Flat
  426.       BackColor       =   &H80000005&
  427.       BackStyle       =   0  'Transparent
  428.       Caption         =   "Using the Text property in the loop:"
  429.       ForeColor       =   &H80000008&
  430.       Height          =   250
  431.       Index           =   0
  432.       Left            =   2145
  433.       TabIndex        =   9
  434.       Top             =   585
  435.       Width           =   3105
  436.    End
  437. Attribute VB_Name = "Code"
  438. Attribute VB_GlobalNameSpace = False
  439. Attribute VB_Creatable = False
  440. Attribute VB_TemplateDerived = False
  441. Attribute VB_PredeclaredId = True
  442. Attribute VB_Exposed = False
  443. Private Sub cmdExplicit_Click()
  444. 'Use the explicit property (txtValue.Text) reference
  445. 'Sub cmdValue_Click is slightly faster
  446.     Limit% = Val(txtValue)
  447.     Screen.MousePointer = 11
  448.     start = Timer
  449.     For x% = 1 To Limit%
  450.         foo$ = txtValue.TEXT
  451.     Next x%
  452.     Finish = Timer
  453.     Screen.MousePointer = 0
  454.     lblExplicit = Format$(Finish - start, "##.##") & " secs."
  455. End Sub
  456. Private Sub cmdInteger_Click()
  457. 'Use an Integer as the Loop Counter
  458. 'faster than Sub cmdVariant_Click
  459. Dim intCounter1 As Integer, intCounter2 As Integer, intCounter3 As Integer
  460.     Screen.MousePointer = 11
  461.     start = Timer
  462.     For intCounter1 = 1 To 100
  463.         For intCounter2 = 1 To intCounter1
  464.             For intCounter3 = 1 To intCounter2
  465.                 VAR = intCounter3 * 100 + intCounter2 * 10 + intCounter1
  466.             Next intCounter3
  467.         Next intCounter2
  468.     Next intCounter1
  469.     Finish = Timer
  470.     Screen.MousePointer = 0
  471.     lblInteger = Format$(Finish - start, "##.##") & " secs."
  472. End Sub
  473. Private Sub cmdProperty_Click()
  474. 'In each iteration, reference the Text Property
  475. 'Sub cmdVariable_Click is faster
  476.     Limit% = Val(txtCounter.TEXT)
  477.     Screen.MousePointer = 11
  478.     start = Timer
  479.     For x% = 1 To Limit%
  480.         foo$ = Left(txtCounter.TEXT, Len(txtCounter.TEXT) \ 2)
  481.     Next x%
  482.     Finish = Timer
  483.     Screen.MousePointer = 0
  484.     lblProperty = Format$(Finish - start, "##.##") & " secs."
  485. End Sub
  486. Private Sub cmdValue_Click()
  487. 'Use the Value of the control by omitting the explicit Text property
  488. 'slightly faster than Sub cmdExplicit_Click
  489.     Limit% = Val(txtValue)
  490.     Screen.MousePointer = 11
  491.     start = Timer
  492.     For x% = 1 To Limit%
  493.         foo$ = txtValue
  494.     Next x%
  495.     Finish = Timer
  496.     Screen.MousePointer = 0
  497.     lblValue = Format$(Finish - start, "##.##") & " secs."
  498. End Sub
  499. Private Sub cmdVariable_Click()
  500. 'Use a Variable (Temp$) instead of a Property Access
  501. 'faster than Sub cmdProperty_Click
  502.     Limit% = Val(txtCounter.TEXT)
  503.     Temp$ = txtCounter.TEXT
  504.     Screen.MousePointer = 11
  505.     start = Timer
  506.     For x% = 1 To Limit%
  507.         foo$ = Left(Temp$, Len(Temp$) \ 2)
  508.     Next x%
  509.     Finish = Timer
  510.     Screen.MousePointer = 0
  511.     lblVariable = Format$(Finish - start, "##.##") & " secs."
  512. End Sub
  513. Private Sub cmdVariant_Click()
  514. 'Use a Variant as the Loop Counter.
  515. 'Sub cmdInteger_Click is faster since it uses a Integer as the Loop Counter
  516.     Screen.MousePointer = 11
  517.     start = Timer
  518.     For varCounter1 = 1 To txtLoopCount.TEXT
  519.         For varCounter2 = 1 To varCounter1
  520.             For varCounter3 = 1 To varCounter2
  521.                 VAR = varCounter3 * 100 + varCounter2 * 10 + varCounter1
  522.             Next varCounter3
  523.         Next varCounter2
  524.     Next varCounter1
  525.     Finish = Timer
  526.     Screen.MousePointer = 0
  527.     lblVariant = Format$(Finish - start, "##.##") & " secs."
  528. End Sub
  529. Private Sub Form_Load()
  530.     PosForm Me
  531.     ' Set default counter values
  532.     txtCounter = 1000
  533.     txtValue = 1000
  534.     txtLoopCount = 100
  535. End Sub
  536.